package cn.tedu.arrangement;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;

public class FullArrangement {
    public static void DFS(List<Integer> candidate, String prefix, HashSet<String> hs) {
        if (prefix.length() != 0 && !hs.contains(prefix) && candidate.size() == 0) {
            System.out.println(prefix);
            hs.add(prefix);
        }

        for (int i = 0; i < candidate.size(); i++) {
            List<Integer> temp = new LinkedList<>(candidate);
            int item = temp.remove(i);
            DFS(temp, prefix + item + ",", hs);
        }
    }

    public static void main(String[] args) {
        Integer[] array = {1, 2, 3};
        List<Integer> list = Arrays.asList(array);
        HashSet<String> hs = new HashSet<>();
        DFS(list, "", hs);
    }
}
